#include <bits/stdc++.h>

#define container_of(ptr, type, member) ({                                \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);              \
        (type *)( (char *)__mptr - offsetof(type, member) );})  

struct gte_ch {
    int a;
    double b;
    long long c;
    long d;
    char e;
};

struct gte_dev {
    int a[100];
    double c[900];
    struct gte_ch chs[1000];
    char d;
};

struct gte_dev gte;

int main() {
    int idx = 763;
    printf("gte addr %p\n", &gte);
    long *ptr = &gte.chs[idx].d;
    printf("d addr %p\n", ptr);
    struct gte_ch* ch = container_of(ptr, struct gte_ch, d);
    struct gte_dev* dev = container_of(ch, struct gte_dev, chs[763]);
    printf("gte addr %p\n", dev);

    return 0;
}